/**
 *  iBizSys 5.0 机器人生产代码（不要直接修改当前代码）
 *  http://www.ibizsys.net
 */
package com.sa.ibiz.demo.srv.demo.entity;


import java.io.Serializable;
import java.util.HashMap;
import java.util.ArrayList;

import javax.persistence.Column;

import java.sql.Timestamp;
import net.ibizsys.paas.data.IDataObject;
import net.ibizsys.paas.data.DataObject;
import net.ibizsys.paas.util.StringHelper;
import net.sf.json.JSONObject;
import net.ibizsys.paas.util.JSONObjectHelper;
import net.ibizsys.paas.xml.XmlNode;
import net.ibizsys.paas.service.ServiceGlobal;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


/**
 * 实体[IBZ5SUPPLIER] 数据对象
 */
public class IBZ5SUPPLIER extends net.ibizsys.paas.entity.EntityBase implements Serializable {

    private static final long serialVersionUID = -1L;
    private static final Log log = LogFactory.getLog(IBZ5SUPPLIER.class);
    /**
     *   实体属性标识[地址]
     */
    public final static String FIELD_ADDRESS = "ADDRESS";
    /**
     *   实体属性标识[逻辑有效标识]
     */
    public final static String FIELD_DELETEFLAG = "DELETEFLAG";
    /**
     *   实体属性标识[邮箱]
     */
    public final static String FIELD_EMAIL = "EMAIL";
    /**
     *   实体属性标识[供应商标识]
     */
    public final static String FIELD_SUPPLIERID = "SUPPLIERID";
    /**
     *   实体属性标识[供应商名称]
     */
    public final static String FIELD_SUPPLIERNAME = "SUPPLIERNAME";

    private final static int INDEX_ADDRESS = 0;
    private final static int INDEX_DELETEFLAG = 1;
    private final static int INDEX_EMAIL = 2;
    private final static int INDEX_SUPPLIERID = 3;
    private final static int INDEX_SUPPLIERNAME = 4;

    private final static HashMap<String, Integer> fieldIndexMap = new HashMap<String, Integer>();
    static {
        fieldIndexMap.put( FIELD_ADDRESS, INDEX_ADDRESS);
        fieldIndexMap.put( FIELD_DELETEFLAG, INDEX_DELETEFLAG);
        fieldIndexMap.put( FIELD_EMAIL, INDEX_EMAIL);
        fieldIndexMap.put( FIELD_SUPPLIERID, INDEX_SUPPLIERID);
        fieldIndexMap.put( FIELD_SUPPLIERNAME, INDEX_SUPPLIERNAME);
    }

    private IBZ5SUPPLIER proxyIBZ5SUPPLIER = null;

    public IBZ5SUPPLIER() {
        super();
    }
    private boolean addressDirtyFlag = false;
    private boolean deleteflagDirtyFlag = false;
    private boolean emailDirtyFlag = false;
    private boolean supplieridDirtyFlag = false;
    private boolean suppliernameDirtyFlag = false;

    @Column(name="address")
    private String address;
    @Column(name="deleteflag")
    private String deleteflag;
    @Column(name="email")
    private String email;
    @Column(name="supplierid")
    private String supplierid;
    @Column(name="suppliername")
    private String suppliername;


    /**
     *  设置属性值[地址]
     *  @param address
     */
    public void setAddress(String address) {

        if(this.getProxyEntity()!=null) {
            this.getProxyEntity().setAddress(address);
            return;
        }
        if(address!=null) {
            address = StringHelper.trimRight(address);
            if(address.length()==0) {
                address = null;
            }
        }
        this.address =  address;
        this.addressDirtyFlag  = true;
    }

    /**
     *  获取属性值[地址]
     */
    public String getAddress() {
        if(this.getProxyEntity()!=null) {
            return this.getProxyEntity().getAddress();
        }
        return this.address;
    }

    /**
     *  获取属性值[地址]是否修改
     */
    public boolean isAddressDirty() {
        if(this.getProxyEntity()!=null) {
            return this.getProxyEntity().isAddressDirty();
        }
        return this.addressDirtyFlag;
    }

    /**
     *  重置属性值[地址]
     */
    public void resetAddress() {

        if(this.getProxyEntity()!=null) {
            this.getProxyEntity().resetAddress();
            return;
        }

        this.addressDirtyFlag = false;
        this.address = null;
    }
    /**
     *  设置属性值[逻辑有效标识]
     *  @param deleteflag
     */
    public void setDELETEFLAG(String deleteflag) {

        if(this.getProxyEntity()!=null) {
            this.getProxyEntity().setDELETEFLAG(deleteflag);
            return;
        }
        if(deleteflag!=null) {
            deleteflag = StringHelper.trimRight(deleteflag);
            if(deleteflag.length()==0) {
                deleteflag = null;
            }
        }
        this.deleteflag =  deleteflag;
        this.deleteflagDirtyFlag  = true;
    }

    /**
     *  获取属性值[逻辑有效标识]
     */
    public String getDELETEFLAG() {
        if(this.getProxyEntity()!=null) {
            return this.getProxyEntity().getDELETEFLAG();
        }
        return this.deleteflag;
    }

    /**
     *  获取属性值[逻辑有效标识]是否修改
     */
    public boolean isDELETEFLAGDirty() {
        if(this.getProxyEntity()!=null) {
            return this.getProxyEntity().isDELETEFLAGDirty();
        }
        return this.deleteflagDirtyFlag;
    }

    /**
     *  重置属性值[逻辑有效标识]
     */
    public void resetDELETEFLAG() {

        if(this.getProxyEntity()!=null) {
            this.getProxyEntity().resetDELETEFLAG();
            return;
        }

        this.deleteflagDirtyFlag = false;
        this.deleteflag = null;
    }
    /**
     *  设置属性值[邮箱]
     *  @param email
     */
    public void setEmail(String email) {

        if(this.getProxyEntity()!=null) {
            this.getProxyEntity().setEmail(email);
            return;
        }
        if(email!=null) {
            email = StringHelper.trimRight(email);
            if(email.length()==0) {
                email = null;
            }
        }
        this.email =  email;
        this.emailDirtyFlag  = true;
    }

    /**
     *  获取属性值[邮箱]
     */
    public String getEmail() {
        if(this.getProxyEntity()!=null) {
            return this.getProxyEntity().getEmail();
        }
        return this.email;
    }

    /**
     *  获取属性值[邮箱]是否修改
     */
    public boolean isEmailDirty() {
        if(this.getProxyEntity()!=null) {
            return this.getProxyEntity().isEmailDirty();
        }
        return this.emailDirtyFlag;
    }

    /**
     *  重置属性值[邮箱]
     */
    public void resetEmail() {

        if(this.getProxyEntity()!=null) {
            this.getProxyEntity().resetEmail();
            return;
        }

        this.emailDirtyFlag = false;
        this.email = null;
    }
    /**
     *  设置属性值[供应商标识]
     *  @param supplierid
     */
    public void setSupplierId(String supplierid) {

        if(this.getProxyEntity()!=null) {
            this.getProxyEntity().setSupplierId(supplierid);
            return;
        }
        if(supplierid!=null) {
            supplierid = StringHelper.trimRight(supplierid);
            if(supplierid.length()==0) {
                supplierid = null;
            }
        }
        this.supplierid =  supplierid;
        this.supplieridDirtyFlag  = true;
    }

    /**
     *  获取属性值[供应商标识]
     */
    public String getSupplierId() {
        if(this.getProxyEntity()!=null) {
            return this.getProxyEntity().getSupplierId();
        }
        return this.supplierid;
    }

    /**
     *  获取属性值[供应商标识]是否修改
     */
    public boolean isSupplierIdDirty() {
        if(this.getProxyEntity()!=null) {
            return this.getProxyEntity().isSupplierIdDirty();
        }
        return this.supplieridDirtyFlag;
    }

    /**
     *  重置属性值[供应商标识]
     */
    public void resetSupplierId() {

        if(this.getProxyEntity()!=null) {
            this.getProxyEntity().resetSupplierId();
            return;
        }

        this.supplieridDirtyFlag = false;
        this.supplierid = null;
    }
    /**
     *  设置属性值[供应商名称]
     *  @param suppliername
     */
    public void setSupplierName(String suppliername) {

        if(this.getProxyEntity()!=null) {
            this.getProxyEntity().setSupplierName(suppliername);
            return;
        }
        if(suppliername!=null) {
            suppliername = StringHelper.trimRight(suppliername);
            if(suppliername.length()==0) {
                suppliername = null;
            }
        }
        this.suppliername =  suppliername;
        this.suppliernameDirtyFlag  = true;
    }

    /**
     *  获取属性值[供应商名称]
     */
    public String getSupplierName() {
        if(this.getProxyEntity()!=null) {
            return this.getProxyEntity().getSupplierName();
        }
        return this.suppliername;
    }

    /**
     *  获取属性值[供应商名称]是否修改
     */
    public boolean isSupplierNameDirty() {
        if(this.getProxyEntity()!=null) {
            return this.getProxyEntity().isSupplierNameDirty();
        }
        return this.suppliernameDirtyFlag;
    }

    /**
     *  重置属性值[供应商名称]
     */
    public void resetSupplierName() {

        if(this.getProxyEntity()!=null) {
            this.getProxyEntity().resetSupplierName();
            return;
        }

        this.suppliernameDirtyFlag = false;
        this.suppliername = null;
    }

    /* (non-Javadoc)
     * @see net.ibizsys.paas.entity.EntityBase#onReset()
     */
    @Override
    protected void onReset() {
        IBZ5SUPPLIER.resetAll(this);
        super.onReset();
    }

    /**
     * 重置当前数据对象属性值
     * @param entity
     */
    private static void resetAll(IBZ5SUPPLIER et) {
        et.resetAddress();
        et.resetDELETEFLAG();
        et.resetEmail();
        et.resetSupplierId();
        et.resetSupplierName();
    }

    /* (non-Javadoc)
     * @see net.ibizsys.paas.entity.EntityBase#onFillMap(java.util.HashMap, boolean)
     */
    @Override
    protected void onFillMap(HashMap<String, Object> params, boolean bDirtyOnly) {
        if(!bDirtyOnly || isAddressDirty()) {
            params.put(FIELD_ADDRESS,getAddress());
        }
        if(!bDirtyOnly || isDELETEFLAGDirty()) {
            params.put(FIELD_DELETEFLAG,getDELETEFLAG());
        }
        if(!bDirtyOnly || isEmailDirty()) {
            params.put(FIELD_EMAIL,getEmail());
        }
        if(!bDirtyOnly || isSupplierIdDirty()) {
            params.put(FIELD_SUPPLIERID,getSupplierId());
        }
        if(!bDirtyOnly || isSupplierNameDirty()) {
            params.put(FIELD_SUPPLIERNAME,getSupplierName());
        }
        super.onFillMap(params, bDirtyOnly);
    }

    /* (non-Javadoc)
     * @see net.ibizsys.paas.data.DataObject#get(java.lang.String)
     */
    @Override
    public Object get(String strParamName) throws Exception {
        if(this.getProxyEntity()!=null) {
            return this.getProxyEntity().get(strParamName);
        }

        if(StringHelper.isNullOrEmpty(strParamName))
            throw new Exception("没有指定属性");
        Integer index=fieldIndexMap.get(strParamName.toUpperCase());
        if(index==null)
            return super.get(strParamName);

        return  IBZ5SUPPLIER.get(this, index);
    }

    /**
     * 通过属性标识获取属性值
     * @param et 数据对象
     * @param index 属性标识
     * @return
     * @throws Exception
     */
    private static Object get(IBZ5SUPPLIER et,int index) throws Exception {

        switch(index) {
        case INDEX_ADDRESS:
            return et.getAddress();
        case INDEX_DELETEFLAG:
            return et.getDELETEFLAG();
        case INDEX_EMAIL:
            return et.getEmail();
        case INDEX_SUPPLIERID:
            return et.getSupplierId();
        case INDEX_SUPPLIERNAME:
            return et.getSupplierName();
        default:
            throw new Exception("不明属性标识");
        }
    }

    /* (non-Javadoc)
     * @see net.ibizsys.paas.data.DataObject#set(java.lang.String, java.lang.Object)
     */
    @Override
    public void set(String strParamName,Object objValue) throws Exception {
        if(this.getProxyEntity()!=null) {
            this.getProxyEntity().set(strParamName,objValue);
            return;
        }
        if(StringHelper.isNullOrEmpty(strParamName))
            throw new Exception("没有指定属性");

        Integer index=fieldIndexMap.get(strParamName.toUpperCase());
        if(index==null) {
            super.set(strParamName,objValue);
            return;
        }

        IBZ5SUPPLIER.set(this,index,objValue);
    }

    /**
     * 通过属性标识设定属性值
     * @param et 数据对象
     * @param index 属性标识
     * @param obj 值
     * @throws Exception
     */
    private static void set(IBZ5SUPPLIER et,int index,Object obj) throws Exception {
        switch(index) {
        case INDEX_ADDRESS:
            et.setAddress(DataObject.getStringValue(obj));
            return ;
        case INDEX_DELETEFLAG:
            et.setDELETEFLAG(DataObject.getStringValue(obj));
            return ;
        case INDEX_EMAIL:
            et.setEmail(DataObject.getStringValue(obj));
            return ;
        case INDEX_SUPPLIERID:
            et.setSupplierId(DataObject.getStringValue(obj));
            return ;
        case INDEX_SUPPLIERNAME:
            et.setSupplierName(DataObject.getStringValue(obj));
            return ;
        default:
            throw new Exception("不明属性标识");
        }
    }

    /* (non-Javadoc)
     * @see net.ibizsys.paas.data.DataObject#isNull(java.lang.String)
     */
    @Override
    public boolean isNull(String strParamName) throws Exception {
        if(this.getProxyEntity()!=null) {
            return this.getProxyEntity().isNull(strParamName);
        }
        if(StringHelper.isNullOrEmpty(strParamName))
            throw new Exception("没有指定属性");

        Integer index=fieldIndexMap.get(strParamName.toUpperCase());
        if(index==null)
            return super.isNull(strParamName);

        return  IBZ5SUPPLIER.isNull(this, index);
    }

    /**
     * 判断指定属性值是否为空值
     * @param et
     * @param index
     * @return
     * @throws Exception
     */
    private static boolean isNull(IBZ5SUPPLIER et,int index) throws Exception {

        switch(index) {
        case INDEX_ADDRESS:
            return et.getAddress()==null;
        case INDEX_DELETEFLAG:
            return et.getDELETEFLAG()==null;
        case INDEX_EMAIL:
            return et.getEmail()==null;
        case INDEX_SUPPLIERID:
            return et.getSupplierId()==null;
        case INDEX_SUPPLIERNAME:
            return et.getSupplierName()==null;
        default:
            throw new Exception("不明属性标识");
        }
    }


    /* (non-Javadoc)
     * @see net.ibizsys.paas.data.DataObject#contains(java.lang.String)
     */
    @Override
    public boolean contains(String strParamName) throws Exception {
        if(this.getProxyEntity()!=null) {
            return this.getProxyEntity().contains(strParamName);
        }

        if(StringHelper.isNullOrEmpty(strParamName))
            throw new Exception("没有指定属性");
        Integer index=fieldIndexMap.get(strParamName.toUpperCase());
        if(index==null)
            return super.contains(strParamName);

        return  IBZ5SUPPLIER.contains(this, index);
    }

    /**
     * 获取判断对象是否存在指定属性值
     * @param et
     * @param index
     * @return
     * @throws Exception
     */
    private static boolean contains(IBZ5SUPPLIER et,int index) throws Exception {

        switch(index) {
        case INDEX_ADDRESS:
            return et.isAddressDirty();
        case INDEX_DELETEFLAG:
            return et.isDELETEFLAGDirty();
        case INDEX_EMAIL:
            return et.isEmailDirty();
        case INDEX_SUPPLIERID:
            return et.isSupplierIdDirty();
        case INDEX_SUPPLIERNAME:
            return et.isSupplierNameDirty();
        default:
            throw new Exception("不明属性标识");
        }
    }

    /* (non-Javadoc)
     * @see net.ibizsys.paas.data.DataObject#onFillJSONObject(net.sf.json.JSONObject, boolean)
     */
    @Override
    protected void onFillJSONObject(JSONObject objJSON, boolean bIncludeEmpty) throws Exception {
        fillJSONObject(this,objJSON,bIncludeEmpty);
        super.onFillJSONObject(objJSON, bIncludeEmpty);
    }

    /**
     * 填充当前对象到JSON
     * @param et 当前数据对象
     * @param json JSON对象
     * @param bIncEmpty 是否包括空值
     * @throws Exception
     */
    private static  void fillJSONObject(IBZ5SUPPLIER et,JSONObject json, boolean bIncEmpty) throws Exception {
        if(bIncEmpty||et.getAddress()!=null) {
            JSONObjectHelper.put(json,"address",getJSONValue(et.getAddress()),false);
        }
        if(bIncEmpty||et.getDELETEFLAG()!=null) {
            JSONObjectHelper.put(json,"deleteflag",getJSONValue(et.getDELETEFLAG()),false);
        }
        if(bIncEmpty||et.getEmail()!=null) {
            JSONObjectHelper.put(json,"email",getJSONValue(et.getEmail()),false);
        }
        if(bIncEmpty||et.getSupplierId()!=null) {
            JSONObjectHelper.put(json,"supplierid",getJSONValue(et.getSupplierId()),false);
        }
        if(bIncEmpty||et.getSupplierName()!=null) {
            JSONObjectHelper.put(json,"suppliername",getJSONValue(et.getSupplierName()),false);
        }
    }

    /* (non-Javadoc)
     * @see net.ibizsys.paas.data.DataObject#onFillXmlNode(net.ibizsys.paas.xml.XmlNode, boolean)
     */
    @Override
    protected void onFillXmlNode(XmlNode xmlNode,boolean bIncludeEmpty) throws Exception {
        fillXmlNode(this,xmlNode,bIncludeEmpty);
        super.onFillXmlNode(xmlNode, bIncludeEmpty);
    }

    /**
     * 填充当前对象到Xml节点中
     * @param et 当前数据对象
     * @param node Xml节点
     * @param bIncEmpty 是否包括空值
     * @throws Exception
     */
    private static void fillXmlNode(IBZ5SUPPLIER et,XmlNode node,boolean bIncEmpty) throws Exception {
        if(bIncEmpty||et.getAddress()!=null) {
            Object obj = et.getAddress();
            node.setAttribute("ADDRESS",(obj==null)?"":(String)obj);
        }
        if(bIncEmpty||et.getDELETEFLAG()!=null) {
            Object obj = et.getDELETEFLAG();
            node.setAttribute("DELETEFLAG",(obj==null)?"":(String)obj);
        }
        if(bIncEmpty||et.getEmail()!=null) {
            Object obj = et.getEmail();
            node.setAttribute("EMAIL",(obj==null)?"":(String)obj);
        }
        if(bIncEmpty||et.getSupplierId()!=null) {
            Object obj = et.getSupplierId();
            node.setAttribute("SUPPLIERID",(obj==null)?"":(String)obj);
        }
        if(bIncEmpty||et.getSupplierName()!=null) {
            Object obj = et.getSupplierName();
            node.setAttribute("SUPPLIERNAME",(obj==null)?"":(String)obj);
        }


    }

    /* (non-Javadoc)
     * @see net.ibizsys.paas.entity.EntityBase#onCopyTo(net.ibizsys.paas.data.IDataObject, boolean)
     */
    @Override
    protected void onCopyTo(IDataObject dataEntity, boolean bIncludeEmtpy) throws Exception {
        IBZ5SUPPLIER.copyTo(this,dataEntity,bIncludeEmtpy);
        super.onCopyTo(dataEntity,bIncludeEmtpy);
    }

    /**
     * 复制当前对象数据到目标对象
     * @param et 当前数据对象
     * @param dst 目标数据对象
     * @param bIncEmpty 是否包括空值
     * @throws Exception
     */
    private static void copyTo(IBZ5SUPPLIER et,IDataObject dst,boolean bIncEmpty) throws Exception {
        if(et.isAddressDirty() && (bIncEmpty||et.getAddress()!=null)) {
            dst.set(FIELD_ADDRESS,et.getAddress());
        }
        if(et.isDELETEFLAGDirty() && (bIncEmpty||et.getDELETEFLAG()!=null)) {
            dst.set(FIELD_DELETEFLAG,et.getDELETEFLAG());
        }
        if(et.isEmailDirty() && (bIncEmpty||et.getEmail()!=null)) {
            dst.set(FIELD_EMAIL,et.getEmail());
        }
        if(et.isSupplierIdDirty() && (bIncEmpty||et.getSupplierId()!=null)) {
            dst.set(FIELD_SUPPLIERID,et.getSupplierId());
        }
        if(et.isSupplierNameDirty() && (bIncEmpty||et.getSupplierName()!=null)) {
            dst.set(FIELD_SUPPLIERNAME,et.getSupplierName());
        }
    }

    /* (non-Javadoc)
     * @see net.ibizsys.paas.data.DataObject#remove(java.lang.String)
     */
    @Override
    public boolean remove(String strParamName) throws Exception {
        if(this.getProxyEntity()!=null) {
            return this.getProxyEntity().remove(strParamName);
        }

        if(StringHelper.isNullOrEmpty(strParamName))
            throw new Exception("没有指定属性");
        Integer index=fieldIndexMap.get(strParamName.toUpperCase());
        if(index==null)
            return super.remove(strParamName);
        return  IBZ5SUPPLIER.remove(this, index);
    }

    /**
     * 通过属性标识删除属性值
     * @param entity
     * @param index
     * @return
     * @throws Exception
     */
    private static boolean remove(IBZ5SUPPLIER et,int index) throws Exception {
        switch(index) {
        case INDEX_ADDRESS:
            et.resetAddress();
            return true;
        case INDEX_DELETEFLAG:
            et.resetDELETEFLAG();
            return true;
        case INDEX_EMAIL:
            et.resetEmail();
            return true;
        case INDEX_SUPPLIERID:
            et.resetSupplierId();
            return true;
        case INDEX_SUPPLIERNAME:
            et.resetSupplierName();
            return true;
        default:
            throw new Exception("不明属性标识");
        }
    }






    /**
     *  获取代理的数据对象
     */
    private IBZ5SUPPLIER getProxyEntity() {
        return this.proxyIBZ5SUPPLIER;
    }

    /* (non-Javadoc)
     * @see net.ibizsys.paas.data.DataObject#onProxy(net.ibizsys.paas.data.IDataObject)
     */
    @Override
    protected void onProxy(IDataObject proxyDataObject) {
        this.proxyIBZ5SUPPLIER = null;
        if(proxyDataObject!=null && proxyDataObject instanceof IBZ5SUPPLIER) {
            this.proxyIBZ5SUPPLIER = (IBZ5SUPPLIER)proxyDataObject;
        }

    }

}